/**
 * 
 */
package com.taobao.client.sdk;

import java.util.Map;

import com.google.gwt.user.client.Window;
import com.taobao.client.Data;

/**
 * The input parameters of confirming the receipt of the goods
 * 
 * @author hujingfei.pt
 *
 */
public class ReceiptConfirmRequest extends CommonRequest {
	// The default type
	public final static String DEFAULT_TYPE = "620";
	// The type of the trade.
	private String biz_type;
	// The id of the trade.
	private String biz_order_id;
	// The callback url.
	private String callback_url;
	// The url of the top page.
	private String top_url;
	// The url of the bottom page.
	private String bottom_url;	
	// The height of the top of the page.
	private String top_height;
	// The height of the bottom of the page.
	private String bottom_height;
	
	/**
	 * Default constructor
	 */
	public ReceiptConfirmRequest(){}
	
	/**
	 * Constructor
	 */
	public ReceiptConfirmRequest(String biz_type, String biz_order_id, String callback_url, String top_url, String bottom_url
			, String top_height, String bottom_height) {
		this.biz_type = biz_type;
		this.biz_order_id = biz_order_id;
		this.callback_url = callback_url;
		this.top_url = top_url;
		this.bottom_url = bottom_url;
		this.top_height = top_height;
		this.bottom_height = bottom_height;
	}

	/**
	 * @param pairs the hashmap whose contents are set
	 */
	public void setMapContent(Map<String, String> pairs) {
		pairs.put("method", Data.API_CONFIRMATION_GOODS);
		pairs.put("biz_type", biz_type);
		pairs.put("biz_order_id", biz_order_id);
		pairs.put("callback_url", callback_url);
		pairs.put("top_url", top_url);
		pairs.put("bottom_url", bottom_url);
		pairs.put("top_height", DEFAULT_HEIGHT);
		pairs.put("bottom_height", DEFAULT_HEIGHT);
	}
	
	/**
	 * Initialize unchangable parameters
	 */
	public void initialize() {
		
		setBiz_type(DEFAULT_TYPE);
		
		setCallback_url(Window.Location.getHref());
		// Get the url's protocol, host and port name
		String top_url = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/" + Data.TOP_URL;
		setTop_url(top_url);
					
		String bottom_url = Window.Location.getProtocol() + "//" +  Window.Location.getHost() + "/" + Data.BOTTOM_URL;
		setBottom_url(bottom_url);
		
		setTop_height(DEFAULT_HEIGHT);
		setBottom_height(DEFAULT_HEIGHT);
		
	}
	
	/**
	 * @return the biz_type
	 */
	public String getBiz_type() {
		return biz_type;
	}

	/**
	 * @param bizType the biz_type to set
	 */
	public void setBiz_type(String bizType) {
		biz_type = bizType;
	}

	/**
	 * @return the biz_order_id
	 */
	public String getBiz_order_id() {
		return biz_order_id;
	}

	/**
	 * @param bizOrderId the biz_order_id to set
	 */
	public void setBiz_order_id(String bizOrderId) {
		biz_order_id = bizOrderId;
	}

	/**
	 * @return the callback_url
	 */
	public String getCallback_url() {
		return callback_url;
	}

	/**
	 * @param callbackUrl the callback_url to set
	 */
	public void setCallback_url(String callbackUrl) {
		callback_url = callbackUrl;
	}

	/**
	 * @return the top_url
	 */
	public String getTop_url() {
		return top_url;
	}

	/**
	 * @param topUrl the top_url to set
	 */
	public void setTop_url(String topUrl) {
		top_url = topUrl;
	}

	/**
	 * @return the bottom_url
	 */
	public String getBottom_url() {
		return bottom_url;
	}

	/**
	 * @param bottomUrl the bottom_url to set
	 */
	public void setBottom_url(String bottomUrl) {
		bottom_url = bottomUrl;
	}

	/**
	 * @return the top_height
	 */
	public String getTop_height() {
		return top_height;
	}

	/**
	 * @param topHeight the top_height to set
	 */
	public void setTop_height(String topHeight) {
		top_height = topHeight;
	}

	/**
	 * @return the bottom_height
	 */
	public String getBottom_height() {
		return bottom_height;
	}

	/**
	 * @param bottomHeight the bottom_height to set
	 */
	public void setBottom_height(String bottomHeight) {
		bottom_height = bottomHeight;
	}
	
}
